//  Copyright (c) 2012 M.A. (Thijs) van den Berg, http://sitmo.com/
//
//  Use, modification and distribution are subject to the MIT Software License. 
// (See accompanying file LICENSE.txt)

#include <iostream>
#include <boost/random/mersenne_twister.hpp>
#include <stdfin/random/threefry_engine.hpp>

#include <boost/date_time/posix_time/posix_time_types.hpp>

#define tic  \
boost::posix_time::ptime time_start(boost::posix_time::microsec_clock::local_time() );

#define toc(name, value) \
        boost::posix_time::ptime time_end(boost::posix_time::microsec_clock::local_time() ); \
        boost::posix_time::time_duration duration( time_end - time_start ); \
        double dt = 0.001* duration.total_milliseconds(); \
        std::cout << #name " " << dt << " sec, value " << value << std::endl; 


int main()
{

    /*
    {

    std::cout << "The first 4 random numbers of the default engine.\n";
    stdfin::threefry_engine eng;
    for (int i=0; i<4; ++i)
        std::cout << eng() << "\n";        
    
    std::cout << "\nTwo independent streams.\n";
    stdfin::threefry_engine eng2;
    eng.seed(0);  // reset the first engine (not really necessary)
    eng2.seed(1); // 2nd engine gets a different seed
    for (int i=0; i<4; ++i)
        std::cout <<  eng() << " " << eng2() << "\n";

    std::cout << "\nJump a head 1 billion steps.\n";
    eng.discard(1000000000);
    for (int i=0; i<4; ++i) std::cout << " " << eng() << "\n";
    }
    */
    {
        uint64_t s = 0;
        boost::random::mt19937 eng;
        tic
        for (uint64_t i=0; i<1000000000; ++i) s += eng();
        toc("boost:mersenne:", s);
    }

    
    {
        uint64_t s = 0;
        stdfin::threefry_engine eng;
        tic
        for (uint64_t i=0; i<1000000000; ++i) s += eng();
        toc("three-fry     :", s);
    }
    

    return 0;
}
